﻿using Prism.Services.Dialogs;
using System.Windows;
using System.Windows.Input;

namespace TiaoTiaoCode.AutoUpdate.ServerUI.DialogWindows
{
    /// <summary>
    /// DialogWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MyDialogWindow : Window, IDialogWindow
    {
        readonly object _originContent;
        object _userContent = default!;

        public MyDialogWindow()
        {
            InitializeComponent();

            btnClose.Click += (s, e) =>
            {
                Close();
            };

            cz.MouseMove += (s, e) =>
            {
                if (e.LeftButton == MouseButtonState.Pressed)
                    DragMove();
            };

            cz.MouseDoubleClick += (s, e) =>
            {
                if (WindowState == WindowState.Maximized)
                    WindowState = WindowState.Normal;
                else
                    WindowState = WindowState.Maximized;
            };

            _originContent = Content;

            Loaded += MyDialogWindow_Loaded;
        }

        private void MyDialogWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // 转换Content对象，将UserDialog转为弹窗内容
            _userContent = Content;

            Content = _originContent;

            UserContent.Content = _userContent;
        }

        public IDialogResult Result { get; set; } = default!;
    }
}
